
const requestFn = require('../common/requestFn');
const { toDate } = require('../utils/util');
const API = {
  login: "/login", // 登录接口
  isLogin:"/isLogin", //检查是否有token
  getBanner:"/getBanner", 
  getActivityList:"/getActivityList", 
  getPage:"/getPage",
  getEnterpriseInfo:"/getEnterpriseInfo", //企业详情
  getActivityInfoDesc:"/getActivityInfoDesc", //活动详情
  addActivityInfo:"/addActivityInfo",
  getEnterpriseCate:"/getEnterpriseCate",
  getEnterpriseLits:"/getEnterpriseLits",
  orderActivityList:"/orderActivityList",
  addJoiningMembership:"/addJoiningMembership",
  joinMember:"/joinMember",
  getPage:"/getPage",


  phoneLogin:"/decryptPhone",
  creatOrdel:"/payCard?pay_channel=4",
  orderList:"/orderList", //占卜列表
  shopList:"/shopList", //商城首页列表
  
  getClass:"/getClass", // 商城首页分类接口
  shopChildList:"/shopList", //商城二级页面获取商品接口
  classContent:"/getPage", //首页占卜课程接口
  getConfig:"/getConfig", //首页接口
  userClock:"/userClock", //首页打卡接口
  addShopCart:"/addShopCart", //加入购物车
  goodsInfo:"/goodsInfo", //商品详情信息接口
  cartList:"/cartList", //购物车列表
  getAddressInfo:"/getAddressInfo", //个人中心我的地址接口
  getAddressDetailsInfo:"/getAddressDetailsInfo", //我的地址页面获取地址接口
  updateAddressInfo:"/updateAddressInfo" , //保存我的地址接口
  updateAddressDefault:"/updateAddressDefault", //管理我的收货地址刷新列表接口
  getShopInfo:"/getShopInfo" , //购物车结算按钮接口
  shopCreateOrder:"/shopCreateOrder", //创建订单号接口
  shopPay:"/shopPay", //商品购买拉起支付接口
  goodOrderList:"/goodOrderList", //我的订单列表
  shopOrderInfo:"/shopOrderInfo" ,//我的订单详情接口
  userRechargeList:"/userRechargeList", //充值订单接口
  updateUserInfo:"/updateUserInfo", //授权保存头像和昵称接口
  updateShopCart:"/updateShopCart", //购物车加减和数字监听接口
  getCourseList:"/getCourseList", //占卜课程列表接口
  courseCreateOrder:"/courseCreateOrder", //占卜课程拉起支付接口
  coursePay:"/coursePay", //占卜课程支付接口
  updateCoursePlayNum:"/updateCoursePlayNum", //更新课程学习次数
};
// const API = {
//   login: "/login", // 登录接口
//   isLogin:"/isLogin", //检查是否有token
//   phoneLogin:"/decryptPhone",
//   creatOrdel:"/payCard?pay_channel=4",
//   orderList:"/orderList", //占卜列表
//   shopList:"/shopList", //商城首页列表
//   getBanner:"/getBanner", 
//   getClass:"/getClass", // 商城首页分类接口
//   shopChildList:"/shopList", //商城二级页面获取商品接口
//   classContent:"/getPage", //首页占卜课程接口
//   getConfig:"/getConfig", //首页接口
//   userClock:"/userClock", //首页打卡接口
//   addShopCart:"/addShopCart", //加入购物车
//   goodsInfo:"/goodsInfo", //商品详情信息接口
//   cartList:"/cartList", //购物车列表
//   getAddressInfo:"/getAddressInfo", //个人中心我的地址接口
//   getAddressDetailsInfo:"/getAddressDetailsInfo", //我的地址页面获取地址接口
//   updateAddressInfo:"/updateAddressInfo" , //保存我的地址接口
//   updateAddressDefault:"/updateAddressDefault", //管理我的收货地址刷新列表接口
//   getShopInfo:"/getShopInfo" , //购物车结算按钮接口
//   shopCreateOrder:"/shopCreateOrder", //创建订单号接口
//   shopPay:"/shopPay", //商品购买拉起支付接口
//   goodOrderList:"/goodOrderList", //我的订单列表
//   shopOrderInfo:"/shopOrderInfo" ,//我的订单详情接口
//   userRechargeList:"/userRechargeList", //充值订单接口
//   updateUserInfo:"/updateUserInfo", //授权保存头像和昵称接口
//   updateShopCart:"/updateShopCart", //购物车加减和数字监听接口
//   getCourseList:"/getCourseList", //占卜课程列表接口
//   courseCreateOrder:"/courseCreateOrder", //占卜课程拉起支付接口
//   coursePay:"/coursePay", //占卜课程支付接口
//   updateCoursePlayNum:"/updateCoursePlayNum", //更新课程学习次数
// };
const HTTP = {
  /**
  * banner
  * @param {String} userId - 用户ID
  * @param {String} appClientTypeCode - 设备端类型DICT_APP_CLIENT_TYPE_CODE_ANDROID（安卓DICT_APP_CLIENT_TYPE_CODE_IOS（苹果）
  * @param {use} 引用
  * const $api = require('../../common/api.js').HTTP;
    Page({
        data: {},
        onLoad() {
            this.loadData();
            $api.getsiwper().then((res) => {
                console.log(res.data);
                this.swiperList = res.data.data;
            })
            .catch((error) => {
                console.log(error);
            }
        }
    })
  */
    wxLogin(data){
        return requestFn.Request({
            url:API.login,
            data:{
                'code':data.code,
                'userinfo':data.userinfo
            },
            method:'POST',
        })
    },
    isLogin(data){
        return requestFn.Request({
            url:API.isLogin,
            data:{},
            method:'POST',
        })
    },
    phoneWxLogin(data){
        return requestFn.Request({
            url:API.phoneLogin,
            data:{
                'code':data.code,
                'iv':data.iv,
                'encryptedData':data.encryptedData,
            },
            method:'POST',
        })
    },
    addJoiningMembership(data){
      return requestFn.Request({
        url:API.addJoiningMembership,
        data:data,
        method:'POST',
      })
    },
    getPage(data){
      return requestFn.Request({
        url:API.getPage,
        data:data,
        method:'POST',
      })
    },
    joinMember(data){
      return requestFn.Request({
        url:API.joinMember,
        data:data,
        method:'POST',
      })
    },
    getPage(data){
      return requestFn.Request({
        url:API.getPage,
        data:data,
        method:'POST',
      })
    },
    getEnterpriseInfo(data){
      return requestFn.Request({
        url:API.getEnterpriseInfo,
        data:data,
        method:'POST',
      })
    },
    orderActivityList(data){
      return requestFn.Request({
        url:API.orderActivityList,
        data:data,
        method:'POST',
      })
    },
    getEnterpriseLits(data){
      return requestFn.Request({
        url:API.getEnterpriseLits,
        data:data,
        method:'POST',
      })
    },
    getEnterpriseCate(data){
      return requestFn.Request({
        url:API.getEnterpriseCate,
        data:data,
        method:'POST',
      })
    },
    getActivityInfoDesc(data){
      return requestFn.Request({
        url:API.getActivityInfoDesc,
        data:{
            id:data.id
        },
        method:'POST',
      })
    },
    addActivityInfo(data){
      return requestFn.Request({
        url:API.addActivityInfo,
        data:{
          id:data.id,
          type:data.type,
          name:data.name,
          phone:data.phone
        },
        method:'POST',
      })
    },
    updateUserInfo(data){
        return requestFn.Request({
            url:API.updateUserInfo,
            data:{
                nickname:data.nickname,
                head_img:data.head_img,
            },
            method:'POST',
        })
    },
    getActivityList(data){
      return requestFn.Request({
        url:API.getActivityList,
        data:{
            page:data.page,
            limit:data.limit
        },
        method:'POST',
    })
    },
    getRankList(data){
         return requestFn.Request({
            url:API.getRankList,
            data:{
                'num':data.num,
            },
            method:'POST',
        })
    },
    creatOrdel(data){
        return requestFn.Request({
            url:API.creatOrdel,
            data:{
                // code:data.code,
                order_no:data.order_no
            },
            method:'POST',
        })
    },
    shopPay(data){
        return requestFn.Request({
            url:API.shopPay,
            data:{
                // code:data.code,
                order_no:data.order_no
            },
            method:'POST',
        })
    },
    coursePay(data){
      return requestFn.Request({
          url:API.coursePay,
          data:{
              // code:data.code,
              order_no:data.order_no
          },
          method:'POST',
      })
  },
    orderList(data){
        return requestFn.Request({
            url:API.orderList,
            data:{
                p_type:data.p_type,
                limit:data.limit,
                page:data.page
            },
            method:'POST',
        })
    },
    shopList(data){
        return requestFn.Request({
            url:API.shopList,
            data:{
                select_type:data.select_type,
                limit:data.limit,
                page:data.page
            },
            method:'POST',
        })
    },
    updateShopCart(data){
        return requestFn.Request({
            url:API.updateShopCart,
            data:{
                id:data.id,
                num:data.num
            },
            method:'POST',
        })
    },
    cartList(data){
        return requestFn.Request({
            url:API.cartList,
            data:{
                limit:data.limit,
                page:data.page
            },
            method:'POST',
        })
    },
    getBanner(data){
        // type  1=>首页benner 2=>商城首页banner
        return requestFn.Request({
            url:API.getBanner,
            data:{
                type:data.type
            },
            method:'POST',
        })
    },
    getClass(data){
        return requestFn.Request({
            url:API.getClass,
            data:{
                pid:data.pid
            },
            method:'POST',
        })
    },
    shopChildList(data){
        return requestFn.Request({
            url:API.shopChildList,
            data:{
                pid:data.pid,
                class_id:data.class_id,
                select_type:data.select_type,
                page:data.page,
                limit:data.limit
            },
            method:'POST',
        })
    },
    classContent(data){
        return requestFn.Request({
            url:API.classContent,
            data:{
                a:1
            },
            method:'POST',
        })
    },
    getConfig(data){
        return requestFn.Request({
            url:API.getConfig,
            data:{
                a:1
            },
            method:'POST',
        })
    },
    userClock(data){
        return requestFn.Request({
            url:API.userClock,
            data:{
                a:1
            },
            method:'POST',
        })
    },
    addShopCart(data){
        return requestFn.Request({
            url:API.addShopCart,
            data:{
                shop_goods_id:data.shop_goods_id,
                num:data.num
            },
            method:'POST',
        })
    },
    goodsInfo(data){
        return requestFn.Request({
            url:API.goodsInfo,
            data:{
                id:data.id
            },
            method:'POST',
        })
    },
    getAddressInfo(data){
        return requestFn.Request({
            url:API.getAddressInfo,
            data:{},
            method:'POST',
        })
    },
    getAddressDetailsInfo(data){
        return requestFn.Request({
            url:API.getAddressDetailsInfo,
            data:{
                address_id:data.address_id
            },
            method:'POST',
        })
    },
    updateAddressInfo(data){
        return requestFn.Request({
            url:API.updateAddressInfo,
            data:{
                id:data.id,
                address:data.address,
                phone:data.phone,
                name:data.name,
                area:data.area
            },
            method:'POST',
        })
    },
    updateAddressDefault(data){
        return requestFn.Request({
            url:API.updateAddressDefault,
            data:{
                address_id:data.address_id,
            },
            method:'POST',
        })
    },
    getShopInfo(data){
        return requestFn.Request({
            url:API.getShopInfo,
            data:{
                pay_info:JSON.stringify(data.pay_info),
            },
            method:'POST',
        })
    },
    shopCreateOrder(data){
        return requestFn.Request({
            url:API.shopCreateOrder,
            data:{
                pay_info:JSON.stringify(data.pay_info),
                address_id:data.address_id
            },
            method:'POST',
        })
    },
    goodOrderList(data){
        return requestFn.Request({
            url:API.goodOrderList,
            data:{
                limit:data.limit,
                page:data.page,
                select_status:data.select_status
            },
            method:'POST',
        })
    },
    userRechargeList(data){
        return requestFn.Request({
            url:API.userRechargeList,
            data:{
                limit:data.limit,
                page:data.page,
            },
            method:'POST',
        })
    },
    shopOrderInfo(data){
        return requestFn.Request({
            url:API.shopOrderInfo,
            data:{
                id:data.id,
                order_no:data.order_no
            },
            method:'POST',
        })
    },
    getCourseList(data){
      return requestFn.Request({
        url:API.getCourseList,
        data:{},
        method:'POST',
      })
    },
    courseCreateOrder(data){
      return requestFn.Request({
        url:API.courseCreateOrder,
        data:{
          pay_info:data.pay_info
        },
        method:'POST',
      })
    },
    updateCoursePlayNum(data){
      return requestFn.Request({
        url:API.updateCoursePlayNum,
        data:{
          id:data.id
        },
        method:'POST',
      })
    }
}


module.exports =  {
    HTTP,
};